package myThread;

class Singletonlazy1{

    private volatile static Singletonlazy1 instance = null;

    private static Object locker1 = new Object();

    public static Singletonlazy1 getInstance(){
        if(instance == null){
        synchronized (locker1) {
            if (instance == null) {
                instance = new Singletonlazy1();
            }
        }

        }
        return instance;

    }
    private Singletonlazy1(){

    }
}

public class demo27 {
    public static void main(String[] args) {
        Singletonlazy1 s1 = Singletonlazy1.getInstance();
        Singletonlazy1 s2 = Singletonlazy1.getInstance();
        System.out.println(s1 == s2);//true
        //Singletonlazy1 s3 = new Singletonlazy1();
    }
}
